<?php
    # Print api
    # Functions for the general layout of the website
    # 2012-04-22

	function print_header($caption, $name, $tagline, $altLinkedIn)
	{
        print '<div id="langSwitch">';
        print '<a href="" onclick="toggleCookie(\'lang\', \'fr\', 10);">FR</a> | ';
        print '<a href="" onclick="toggleCookie(\'lang\', \'en\', 10);">EN</a>';
        print '</div>';

		print '<div id="caption">';
		print '<p id="caption_text"><a href="./" alt="' . $caption . '" title="' . $caption . '">' . $caption . '</a></p>';
		print '</div>';
		
		print '<div id="intro">';
		print '<div id="intro_name">' . $name . '</div>';
		print '<div id="tagline"><em>' . $tagline . '</em></div>';

        if (!isset($_COOKIE['lang'])){
            $currLang = 'fr';
        }
        else
            $currLang = $_COOKIE['lang'];

        print '<p id="linkedin"><a href="http://www.linkedin.com/in/adzongo" target="_blank"><img src="gui/img/linkedin_' . $currLang . '.jpg" alt="' . $altLinkedIn . '" title="' . $altLinkedIn . '" /></a>';
		print '</div>';
	}
	
    function print_menu()
	{
		$sql = "SELECT id, surname FROM teams ORDER BY surname ASC";
		$result = mysql_query($sql);
		
		print "<div id='div_menu'>";
		print '<dl class="dropdown_main">
		<dt id="home-ddheader" onmouseover="ddMenu(\'home\',1)" onmouseout="ddMenu(\'home\',-1)"><a href="index.php" target=""><!--<img src="gui/images/homeicon.png" width="9" height="9" border="0">-->Home</a></dt>
		</dl>
		
		<dl class="dropdown_main">
		<dt id="rules-ddheader" onmouseover="ddMenu(\'rules\',1)" onmouseout="ddMenu(\'rules\',-1)"><a href="rules.php" target=""><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Rules</a></dt>
		</dl>
		
		<dl class="dropdown_main">
			<dt id="teams-ddheader" onmouseover="ddMenu(\'teams\',1)" onmouseout="ddMenu(\'teams\',-1)"><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Teams</dt>
			<dd id="teams-ddcontent" onmouseover="cancelHide(\'teams\')" onmouseout="ddMenu(\'teams\',-1)" >
			<ul>';
				while ($row = mysql_fetch_array($result))
				{
					print '<li><a href="teams.php?t=' . $row['id'] . '">' . $row['surname'] . '</a></li>';
				}
		print '</ul>
			</dd>
		</dl>
		
		<dl class="dropdown_main">
		<dt id="games-ddheader" onmouseover="ddMenu(\'games\',1)" onmouseout="ddMenu(\'games\',-1)"><a href="games.php" target=""><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Games</a></dt>
		</dl>
		
		<dl class="dropdown_main">
		<dt id="ptTable-ddheader" onmouseover="ddMenu(\'ptTable\',1)" onmouseout="ddMenu(\'ptTable\',-1)"><a href="points_table.php" target=""><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Points table</a></dt>
		</dl>
		
		<dl class="dropdown_main">
		<dt id="gallery-ddheader" onmouseover="ddMenu(\'gallery\',1)" onmouseout="ddMenu(\'gallery\',-1)"><a href="gallery.php" target=""><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Gallery</a></dt>
		</dl>
		
		<dl class="dropdown_main">
		<dt id="forum-ddheader" onmouseover="ddMenu(\'forum\',1)" onmouseout="ddMenu(\'forum\',-1)"><a href="forum.php" target=""><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Forum</a></dt>
		</dl>
		
		<dl class="dropdown_main">
		<dt id="contacts-ddheader" onmouseover="ddMenu(\'contacts\',1)" onmouseout="ddMenu(\'contacts\',-1)"><a href="contacts.php" target=""><!--<img src="/images/common/nav_arrow.gif" width="9" height="9" border="0"> -->Contacts</a></dt>
		</dl>';
		print "</div>";
	}
	
	function print_footer($copyright)
	{
		print '<div id="copyright">';
		print $copyright;
		print '</div>';
	}
	
	function print_page_title($title)
	{
		/*print '<div id="caption">';
		print '<h2 id="page_title">' . $title . '</h2>';
		print '';
		print '</div>';*/
		print '<div class="entry_title">' . $title . '</div>';
	}
	
	function print_team_description($row)
	{
		print'<table class="table1">';
			print '<tr>';
				print '<td class="title">Logo</td>';
				print '<td><img src="gui/images/logos/' . str_replace(" ", "_", $row['surname']) . '.png" alt="' . $row['surname'] . '\' logo."></td>';
			print '</tr>';
			print '<tr>';
				print '<td class="title">Mosque</td>';
				print '<td>' . $row['name'] . '</td>';
			print '</tr>';
			print '<tr>';
				print '<td class="title">Address</td>';
				print '<td>' . $row['address'] . '</td>';
			print '</tr>';
			print '<tr>';
				print '<td class="title">City</td>';
				print '<td>' . $row['city'] . '</td>';
			print '</tr>';
			print '<tr>';
				print '<td class="title">Contact</td>';
				print '<td>' . $row['contact'] . '</td>';
			print '</tr>';
		print'</table>';
	}
	
	function print_player($row)
	{
		if ($row['captain'] == 1)
			$strCaptain = " (<b>C</b>)";
		else
			$strCaptain = "";
		
		print '<tr>';
		    print '<td>' . $row['lastname'] . '</td>';
		    print '<td>' . $row['firstname'] . '</td>';
		    print '<td>' . $row['position'] . $strCaptain . '</td>';
		    //print '<td>' . $row['age'] . '</td>';
		print '</tr>';
	}

	function print_facebook_link()
	{
		//print '<div class="content_block">';
			//print '<div class="head">Visit us on Facebook</div>';
			//print '<br>';
			//print '<div class="facebook">';
				print 'Visit us on Facebook<br>';
				print '<a href="http://www.facebook.com/imanileague" target="_blank"><img src="gui/images/facebook.jpg" alt="facebook.com/imanileague"></a>';
			//print '</div>';
			//print '<br>';
		//print '</div>';
		
	}
	
	function print_gallery_image($dirname)
	{
		$img_path = "gui/images/pics/" . $dirname;
		if ($handle = opendir($img_path)) {
			
		    /* Loop over the directory. */
		    while (false !== ($entry = readdir($handle))) {
		    	if ($entry != "." && $entry != "..") {
		    		$path_parts = pathinfo($entry);
		        	print '<a href="' . $img_path . '/' . $entry . '">
		              	<img data-title="' . $dirname . '"
		                     data-description="' . $path_parts['filename'] . '"
		                     src="' . $img_path . '/' . $entry . '">
	            	 </a>';
		    	}
		    }
		    closedir($handle);
		}
	}
	
	function print_ptable_row($index, $row)
	{
		print '<tr>';
			print '<td>' . $index . '</td>';
			print '<td>' . $row['name'] . '</td>';
			print '<td>' . $row['matches_played'] . '</td>';
			print '<td>' . $row['win'] . '</td>';
			print '<td>' . $row['loss'] . '</td>';
			print '<td>' . $row['goals_for'] . '</td>';
			print '<td>' . $row['goals_against'] . '</td>';
			print '<td>' . $row['goal_diff'] . '</td>';
			print '<td>' . $row['total_points'] . '</td>';
		print '</tr>';
	}

